package com.liutaw.nanjingair.views.fragments;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ScrollView;

import com.liutaw.nanjingair.R;
import com.liutaw.nanjingair.views.adapter.WeatherHourInfoAdapter;
import com.liutaw.nanjingair.views.viewcomponent.DividerLine;
import com.liutaw.navigationbarlib.NaviBarBuilder;

import butterknife.Bind;
import butterknife.ButterKnife;

public class IndexFragmentBackup extends Fragment {
    @Bind(R.id.navi_container)
    FrameLayout navi_container;
    NaviBarBuilder navigationBarView;
    @Bind(R.id.recycleview_future_hour)
    RecyclerView recycleview_future_hour;
    @Bind(R.id.recycleview_before_hour)
    RecyclerView recycleview_before_hour;
    private WeatherHourInfoAdapter weatherHourInfoAdapter;
    @Bind(R.id.scrollView)
    ScrollView scrollView;

    public IndexFragmentBackup() {
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.layout_fragment_index, container, false);
        ButterKnife.bind(this, view);
        navigationBarView = new NaviBarBuilder(getActivity());
        navigationBarView.buildLeftView().buildImg(R.drawable.icon_topbar_left_index).buildCenterView().buildTitleText("六合区");
        navi_container.addView(navigationBarView.build());
        weatherHourInfoAdapter = new WeatherHourInfoAdapter(getContext());

        initRecyclerView(recycleview_future_hour);//未来24小时
        initRecyclerView(recycleview_before_hour);//过去24小时

        scrollView.setFillViewport(true);

        return view;
    }

    private void initRecyclerView(RecyclerView recyclerView) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setAdapter(weatherHourInfoAdapter);
        DividerLine dividerLine = new DividerLine(DividerLine.HORIZONTAL);
        dividerLine.setSize(1);
        dividerLine.setColor(0x33FFFFFF);
        recyclerView.addItemDecoration(dividerLine);
    }
}
